﻿/**********************************************************************************
 * Project Name :   
 * Remarks      :  
 * Class Name   :  IdleException 
 * Version      :  v1.0.0.0 
 * Author       :  Joey Liang 
 * Description  : 
 * Created Time :  2013/8/14 22:38:59
 * Update Man   :  Joey Liang
 * Update Time  :  2013/8/14 22:38:59
************************************************************************/

using JoeyLibs.Utility;
using JoeyLibs.Utility.Log;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JoeyLibs.IdleStartMenu.Model
{
    public class IdleException : Exception
    {
        private string reason;
        /// <summary>
        /// 异常原因
        /// </summary>
        public string Reason
        {
            get { return reason; }
        }
        
        private string solution;
        /// <summary>
        /// 异常解决办法
        /// </summary>
        public string Solution
        {
            get { return solution; }
        }

        public IdleException(string message, string reason = "", string solution = "") : base(message) 
        {
            this.reason = reason;
            this.solution = solution;
            //createExceptionLog();
        }

        /// <summary>
        /// 日志记录
        /// </summary>
        private void createExceptionLog()
        {
            CreateExceptionLog(this, this.reason);
        }

        /// <summary>
        /// 为异常创建日志
        /// </summary>
        /// <param name="ex">异常对象</param>
        /// <param name="reason">导致异常的原因</param>
        public static void CreateExceptionLog(Exception ex, string reason = "", string solution = "")
        {
            new ExceptionLogModel(ex.Message, reason, solution, ex).Output();
        }
    }
}
